﻿using System.Linq;
using Zinnia.Lite.Core.Imp;

namespace Zinnia.Lite.Core
{
   public  interface IRepository<T> where T : ZinniaBaseLite
    {
        /// <summary>
        /// 仓储中心上下文
        /// </summary>
        IZinniaLiteContext Context { get; }
        /// <summary>
        /// 根据标识获取实体
        /// </summary>
        /// <param name="id">标识</param>
        /// <returns>Entity</returns>
        T Get(object id);

        /// <summary>
        ///添加实体
        /// </summary>
        /// <param name="entity">数据实体</param>
        void Add(T entity);

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="entity">数据实体</param>
        void Change(T entity);      

        /// <summary>
        /// 移除数据
        /// </summary>
        /// <param name="entity">数据实体</param>
        void Remove(T entity);

        /// <summary>
        /// 获取数据表
        /// </summary>
        IQueryable<T> Table { get; }

        /// <summary>
        /// 获取不缓存数据表
        /// </summary>
        IQueryable<T> TableNoTracking { get; }
    }
}

